<?php
/* 	These code was generated using phpCIGen v 0.1.b (24/06/2009)
	#zaqi 		zaqi.smart@gmail.com,http://zenzaqi.blogspot.com, 
	#CV. Trust Solution, jl. Saronojiwo 19 Surabaya, http://www.ts.co.id
	
	+ Module  		: tbl_s_info View
	+ Description	: For record view
	+ Filename 		: v_tbl_s_info.php
 	+ creator  		: 
 	+ Created on 22/Jan/2012 19:08:53
	
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<style type="text/css">
        p { width:650px; }
		.search-item {
			font:normal 11px tahoma, arial, helvetica, sans-serif;
			padding:3px 10px 3px 10px;
			border:1px solid #fff;
			border-bottom:1px solid #eeeeee;
			white-space:normal;
			color:#555;
		}
		.search-item h3 {
			display:block;
			font:inherit;
			font-weight:bold;
			color:#222;
		}
		
		.search-item h3 span {
			float: right;
			font-weight:normal;
			margin:0 0 5px 5px;
			width:100px;
			display:block;
			clear:none;
		}
    </style>
<script>
/* declare function */		
var tbl_s_info_DataStore;
var tbl_s_info_ColumnModel;
var tbl_s_infoListEditorGrid;
var tbl_s_info_saveForm;
var tbl_s_info_saveWindow;
var tbl_s_info_searchForm;
var tbl_s_info_searchWindow;
var tbl_s_info_SelectedRow;
var tbl_s_info_ContextMenu;

//declare konstant
var post2db = '';
var msg = '';
var pageS=15;

/* declare variable here for Field*/
var info_idField;
var info_namaField;
var info_dvoField;
var info_alamatField;
var info_notelpField;
var info_nofaxField;
var info_emailField;
var info_websiteField;
var info_sloganField;
var info_logoField;
var info_iconField;
var info_backgroundField;
var info_themeField;
var info_idSearchField;
var info_namaSearchField;
var info_dvoSearchField;
var info_alamatSearchField;
var info_notelpSearchField;
var info_nofaxSearchField;
var info_emailSearchField;
var info_websiteSearchField;
var info_sloganSearchField;
var info_logoSearchField;
var info_iconSearchField;
var info_backgroundSearchField;
var info_themeSearchField;

/* on ready fuction */
Ext.onReady(function(){
  	Ext.QuickTips.init();	/* Initiate quick tips icon */
  
  	 
  	/* Function for add and edit data form, open window form */
	function tbl_s_info_save(){
	
		if(is_tbl_s_info_form_valid()){
			tbl_s_info_saveForm.getForm().submit({
				method: 'POST',
				waitTitle:'Please wait.....',
				waitMsg:'Proses Upload...',
				url: 'index.php?c=c_tbl_s_info&m=tbl_s_info_update',
				success: function(opt, success, response){
					console.log(response);
					Ext.MessageBox.alert(post2db+' OK','Info Sukses disimpan');
					mainPanel.remove(mainPanel.getActiveTab().getId());
					window.location = 'index.php?c=main';
				}
			});
			/*var info_id_field_pk=null; 
			var info_nama_field=null; 
			var info_dvo_field=null; 
			var info_alamat_field=null; 
			var info_notelp_field=null; 
			var info_nofax_field=null; 
			var info_email_field=null; 
			var info_website_field=null; 
			var info_slogan_field=null; 
			var info_logo_field=null; 
			var info_icon_field=null; 
			var info_background_field=null; 
			var info_theme_field=null; 

			if(info_namaField.getValue()!== null){info_nama_field = info_namaField.getValue();} 
			if(info_dvoField.getValue()!== null){info_dvo_field = info_dvoField.getValue();} 
			if(info_alamatField.getValue()!== null){info_alamat_field = info_alamatField.getValue();} 
			if(info_notelpField.getValue()!== null){info_notelp_field = info_notelpField.getValue();} 
			if(info_nofaxField.getValue()!== null){info_nofax_field = info_nofaxField.getValue();} 
			if(info_emailField.getValue()!== null){info_email_field = info_emailField.getValue();} 
			if(info_websiteField.getValue()!== null){info_website_field = info_websiteField.getValue();} 
			if(info_sloganField.getValue()!== null){info_slogan_field = info_sloganField.getValue();} 
			console.log("logo = "+info_logoField.getValue());
			if(info_logoField.getValue()!== null){info_logo_field = info_logoField.getValue();} 
			if(info_iconField.getValue()!== null){info_icon_field = info_iconField.getValue();} 
			if(info_backgroundField.getValue()!== null){info_background_field = info_backgroundField.getValue();} 
			if(info_themeField.getValue()!== null){info_theme_field = info_themeField.getValue();} 

			Ext.MessageBox.show({
				msg: 'Sedang menyimpan data, silakan tunggu...',
				progressText: 'Loading...',
				width:350,
				wait:true,
				icon:'icon-sync'
			});
			
			Ext.Ajax.request({  
				waitMsg: 'Please wait...',
				url: 'index.php?c=c_tbl_s_info&m=get_action',
				params: {
					info_nama	: info_nama_field, 
					info_dvo	: info_dvo_field, 
					info_alamat	: info_alamat_field, 
					info_notelp	: info_notelp_field, 
					info_nofax	: info_nofax_field, 
					info_email	: info_email_field, 
					info_website	: info_website_field, 
					info_slogan	: info_slogan_field, 
					info_logo	: info_logo_field, 
					info_icon	: info_icon_field, 
					info_background	: info_background_field, 
					info_theme	: info_theme_field, 
					task: post2db
				}, 
				success: function(response){             
					var result=eval(response.responseText);
					switch(result){
						case 1:
							Ext.MessageBox.alert(post2db+' OK','Info Sukses disimpan');
							tbl_s_info_DataStore.reload();
							mainPanel.remove(mainPanel.getActiveTab().getId());
							break;
						default:
							Ext.MessageBox.show({
							   title: 'Warning',
							   msg: 'Info gagal disimpan.',
							   buttons: Ext.MessageBox.OK,
							   animEl: 'save',
							   icon: Ext.MessageBox.WARNING
							});
							break;
					}        
				},
				failure: function(response){
					var result=response.responseText;
					Ext.MessageBox.show({
						   title: 'Error',
						   msg: 'Could not connect to the database. retry later.',
						   buttons: Ext.MessageBox.OK,
						   animEl: 'database',
						   icon: Ext.MessageBox.ERROR
					});	
				}                      
			});*/
			
		} else {
			Ext.MessageBox.show({
				title: 'Warning',
				msg: 'Your Form is not valid!.',
				buttons: Ext.MessageBox.OK,
				animEl: 'save',
				icon: Ext.MessageBox.WARNING
			});
		}
	}
 	/* End of Function */
  /* Function for Retrieve DataStore */
	tbl_s_dvo_DataStore = new Ext.data.Store({
		id: 'tbl_s_dvo_DataStore',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_m_dvo&m=get_action', 
			method: 'POST'
		}),
		baseParams:{task: "LIST"}, // parameter yang di $_POST ke Controller
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total',
			id: 'dvo_id'
		},[
			{name: 'dvo_id', type: 'int', mapping: 'dvo_id'}, 
			{name: 'dvo_name', type: 'string', mapping: 'dvo_name'}
		]),
		sortInfo:{field: 'dvo_id', direction: "ASC"}
	});
	/* End of Function */
	
  		
	/* Function for Check if the form is valid */
	function is_tbl_s_info_form_valid(){
		return (info_namaField.isValid() &&
				info_dvoField.isValid() );
	}
  	/* End of Function */
  
  	/* Function for Displaying  create Window Form */
	function display_form_window(){
		if(!tbl_s_info_saveWindow.isVisible()){
			tbl_s_info_reset_form();
			post2db='CREATE';
			msg='created';
			tbl_s_info_saveWindow.show();
		} else {
			tbl_s_info_saveWindow.toFront();
		}
	}
  	/* End of Function */
   
	/* Function for Retrieve DataStore */
	tbl_s_info_DataStore = new Ext.data.Store({
		id: 'tbl_s_info_DataStore',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_tbl_s_info&m=get_action', 
			method: 'POST'
		}),
		baseParams:{task: "LIST"}, // parameter yang di $_POST ke Controller
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total',
			id: 'info_id'
		},[
			{name: 'info_id', type: 'int', mapping: 'info_id'}, 
			{name: 'info_nama', type: 'string', mapping: 'info_nama'}, 
			{name: 'info_dvo', type: 'int', mapping: 'info_dvo'}, 
			{name: 'info_dvo_nama', type: 'string', mapping: 'dvo_name'}, 
			{name: 'info_alamat', type: 'string', mapping: 'info_alamat'}, 
			{name: 'info_notelp', type: 'string', mapping: 'info_notelp'}, 
			{name: 'info_nofax', type: 'string', mapping: 'info_nofax'}, 
			{name: 'info_email', type: 'string', mapping: 'info_email'}, 
			{name: 'info_website', type: 'string', mapping: 'info_website'}, 
			{name: 'info_slogan', type: 'string', mapping: 'info_slogan'}, 
			{name: 'info_logo', type: 'string', mapping: 'info_logo'}, 
			{name: 'info_icon', type: 'string', mapping: 'info_icon'}, 
			{name: 'info_background', type: 'string', mapping: 'info_background'}, 
			{name: 'info_theme', type: 'string', mapping: 'info_theme'} 
		]),
		sortInfo:{field: 'info_id', direction: "DESC"}
	});
	/* End of Function */
   
	/* Identify  info_nama Field */
	info_namaField= new Ext.form.TextField({
		id: 'info_namaField',
		name: 'info_nama',
		fieldLabel: 'Nama Perusahaan',
		maxLength: 150,
		allowBlank: false,
		anchor: '95%'
	});

	info_dvoField= new Ext.form.ComboBox({
		id: 'info_dvoField',
		name: 'info_dvo_nama',
		fieldLabel: 'DVO',
		store: tbl_s_dvo_DataStore,
		mode: 'remote',
		displayField:'dvo_name',
		valueField: 'dvo_id',
        editable: true,
        allowBlank: false,
		anchor: '95%',
		pageSize: 15,
		triggerAction: 'all',
		forceSelection:true
	});
	
	/* Identify  info_alamat Field */
	info_alamatField= new Ext.form.TextArea({
		id: 'info_alamatField',
		name: 'info_alamat',
		fieldLabel: 'Alamat',
		maxLength: 250,
		anchor: '95%'
	});
	
	/* Identify  info_notelp Field */
	info_notelpField= new Ext.form.TextField({
		id: 'info_notelpField',
		name: 'info_notelp',
		fieldLabel: 'No Telepon',
		maxLength: 50,
		anchor: '70%',
		maskRe: /([0-9+;-]+)$/
	});
	/* Identify  info_nofax Field */
	info_nofaxField= new Ext.form.TextField({
		id: 'info_nofaxField',
		name: 'info_nofax',
		fieldLabel: 'No Faximile',
		maxLength: 50,
		anchor: '70%',
		maskRe: /([0-9+;-]+)$/
	});
	/* Identify  info_email Field */
	info_emailField= new Ext.form.TextField({
		id: 'info_emailField',
		name:'info_email',
		fieldLabel: 'Email',
		maxLength: 50,
		anchor: '95%'
	});
	/* Identify  info_website Field */
	info_websiteField= new Ext.form.TextField({
		id: 'info_websiteField',
		name: 'info_website',
		fieldLabel: 'Website',
		maxLength: 100,
		anchor: '95%'
	});
	/* Identify  info_slogan Field */
	info_sloganField= new Ext.form.TextField({
		id: 'info_sloganField',
		name: 'info_slogan',
		fieldLabel: 'Slogan',
		maxLength: 150,
		anchor: '95%'
	});
	/* Identify  info_logo Field */
	/*info_logoField= new Ext.form.FileUploadField({
		id: 'info_logoField',
		name: 'info_logo',
		fieldLabel: 'Logo',
		emptyText: 'Select an image',
		maxLength: 150,
		anchor: '95%',
		buttonText: '',
        buttonCfg: {
            iconCls: 'icon-upload'
        }
	});*/
	/* Identify  info_icon Field */
	info_iconField= new Ext.form.TextField({
		id: 'info_iconField',
		name: 'info_icon',
		fieldLabel: 'Icon',
		maxLength: 150,
		anchor: '95%'
	});
	/* Identify  info_background Field */
	/* info_backgroundField= new Ext.form.TextField({
		id: 'info_backgroundField',
		name: 'info_background',
		fieldLabel: 'Background',
		maxLength: 150,
		anchor: '95%'
	}); */
	/* Identify  info_theme Field */
	info_themeField= new Ext.form.TextField({
		id: 'info_themeField',
		name : 'info_theme',
		fieldLabel: 'Theme',
		maxLength: 150,
		anchor: '95%'
	});

	
	/* Function for retrieve create Window Panel*/ 
	tbl_s_info_saveForm = new Ext.FormPanel({
		labelAlign: 'left',
		bodyStyle:'padding:5px',
		autoHeight:true,
		frame : true,
		renderTo: 'elwindow_tbl_s_info_save',
		title: post2db+' Infomasi Perusahaan',
		url: 'index.php?c=c_tbl_s_info&m=tbl_s_info_list',
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total',
			id: 'info_id'
		},[
			{name: 'info_id', type: 'int', mapping: 'info_id'}, 
			{name: 'info_nama', type: 'string', mapping: 'info_nama'}, 
			{name: 'info_dvo', type: 'int', mapping: 'info_dvo'}, 
			{name: 'info_dvo_nama', type: 'string', mapping: 'dvo_name'}, 
			{name: 'info_alamat', type: 'string', mapping: 'info_alamat'}, 
			{name: 'info_notelp', type: 'string', mapping: 'info_notelp'}, 
			{name: 'info_nofax', type: 'string', mapping: 'info_nofax'}, 
			{name: 'info_email', type: 'string', mapping: 'info_email'}, 
			{name: 'info_website', type: 'string', mapping: 'info_website'}, 
			{name: 'info_slogan', type: 'string', mapping: 'info_slogan'}, 
			{name: 'info_logo', type: 'string', mapping: 'info_logo'}, 
			{name: 'info_icon', type: 'string', mapping: 'info_icon'}, 
			{name: 'info_background', type: 'string', mapping: 'info_background'}, 
			{name: 'info_theme', type: 'string', mapping: 'info_theme'} 
		]),
		width: 500,
		fileUpload: true,
		items:[
			{
				columnWidth:1,
				layout: 'form',
				border:false,
				items: [info_namaField, info_dvoField, info_alamatField, 
						info_notelpField, info_nofaxField, info_emailField, 
						info_websiteField, info_sloganField/* ,{xtype: 'fileuploadfield', 
							id: 'info_logoField', 
							name: 'info_logo',
							emptyText: 'Select an image', 
							fieldLabel: 'Logo', 
							maxLength: 150,
							anchor: '95%',
							buttonText: '',
					        buttonCfg: {
					            iconCls: 'icon-upload'
					        }
						},{
							xtype:'fileuploadfield',
							id:'info_backgroundField',
							name:'info_background',
							emptyText:'Select a background',
							fieldLabel:'Background',
							maxLenght:150,
							anchor:'95%',
							buttonText:'',
							buttonCfg:{
								iconCls:'icon-upload'
							}
						} */] 
			}
			],
		buttons: [{
				text: 'Simpan',
				handler: tbl_s_info_save
			}
			,{
				text: 'Batal',
				handler: function(){
					mainPanel.remove(mainPanel.getActiveTab().getId());
				}
			}
		]
	});
	
	tbl_s_info_saveForm.on('beforerender',function(){

		Ext.MessageBox.show({
			msg: 'Sedang memuat data, silakan tunggu...',
			progressText: 'Loading...',
			width:350,
			wait:true,
			icon:'icon-sync'
		});
		
	});

	tbl_s_info_saveForm.on('render',function(){
		Ext.MessageBox.hide();
	});
	
	tbl_s_info_saveForm.getForm().load();
	post2db='UPDATE';
	
	
});
	</script>
<body>
<div>
	<div class="col">
        <div id="fp_tbl_s_info"></div>
		<div id="elwindow_tbl_s_info_save"></div>
        <div id="elwindow_tbl_s_info_search"></div>
    </div>
</div>
</body>
</html>